<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.5 of April 16, 2007 on October 19, 2007 at 6:14:48 am</time-stamp>


<class>
<name>Planet</name>
<environment>SpaceTrader</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>cargo wormhole xylocation mercenaries visited techlevel polsystem </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SpaceTrader</category>
<attributes>
<package>SpaceTrader</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SpaceTrader.Planet class</class-id> <category>instance creation</category>

<body package="SpaceTrader" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SpaceTrader.Planet</class-id> <category>initialize-release</category>

<body package="SpaceTrader" selector="GenerateEncounters">GenerateEncounters
	"Need to create Encounter class -&gt; NPC class -&gt; Character class -&gt; Person class"</body>

<body package="SpaceTrader" selector="GenerateGoods">GenerateGoods
	"Generate the goods for the planet depending on the Tech level"
	cargo water: (self GenerateGoodsNum: #Water).
	cargo waterprice: (self GenerateGoodsPrice: #Water).

	cargo furs: (self GenerateGoodsNum: #Furs).
	cargo fursprice: (self GenerateGoodsPrice: #Furs).

	cargo food: (self GenerateGoodsNum: #Food).
	cargo foodprice: (self GenerateGoodsPrice: #Food).

	cargo ore: (self GenerateGoodsNum: #Ore).
	cargo oreprice: (self GenerateGoodsPrice: #Ore).

	cargo games: (self GenerateGoodsNum: #Games).
	cargo gamesprice: (self GenerateGoodsPrice: #Games).

	cargo firearms: (self GenerateGoodsNum: #Firearms).
	cargo firearmsprice: (self GenerateGoodsPrice: #Firearms).

	cargo medicine: (self GenerateGoodsNum: #Medicine).
	cargo medicineprice: (self GenerateGoodsPrice: #Medicine).

	cargo machines: (self GenerateGoodsNum: #Machines).
	cargo machinesprice: (self GenerateGoodsPrice: #Machines).

	cargo narcotics: (self GenerateGoodsNum: #Narcotics).
	cargo narcoticsprice: (self GenerateGoodsPrice: #Narcotics).

	cargo robots: (self GenerateGoodsNum: #Robots).
	cargo robotsprice: (self GenerateGoodsPrice: #Robots).

	cargo totalcargo: (cargo water) + (cargo furs) + (cargo food) + (cargo ore) + (cargo games) + (cargo firearms) + (cargo medicine) + (cargo machines) + (cargo narcotics) + (cargo robots).</body>

<body package="SpaceTrader" selector="GenerateGoodsNum:">GenerateGoodsNum: itemType
"((Enums CargoItems at: thisItem) &gt;= (Enums CargoItems at: #Water)) ifTrue: [(Enums TradeItems at: thisItem)"
	|cargonum random selftechlevel mintechlevel thissize|

	selftechlevel := (Enums TechLevels at: (self techlevel)).
	mintechlevel := (Enums TechLevels at: ((Enums TradeItems at: (Enums CargoItems at: itemType)  ) at: 1)).
	thissize := (Enums PlanetSize at: (self planetsize)).
	random := Random new.

	(selftechlevel &gt;= mintechlevel) 
		ifTrue: [cargonum := (thissize) + ( (random between: 9 and: 14) * ((selftechlevel - mintechlevel) + 1) )]
		ifFalse: [cargonum := 0].

	^cargonum.</body>

<body package="SpaceTrader" selector="GenerateGoodsPrice:">GenerateGoodsPrice: itemType

	|price baseprice priceinc selftechlevel mintechlevel thissize|

	selftechlevel := (Enums TechLevels at: (self techlevel)).
	mintechlevel := (Enums TechLevels at: ((Enums TradeItems at: (Enums CargoItems at: itemType)  ) at: 1)).
	baseprice := ((Enums TradeItems at: (Enums CargoItems at: itemType)  ) at: 2).
	priceinc := ((Enums TradeItems at: (Enums CargoItems at: itemType)  ) at: 3).
	thissize := (Enums PlanetSize at: (self planetsize)).
	
	(selftechlevel &gt;= mintechlevel)
		ifTrue: 
		[
			price := baseprice + (selftechlevel * priceinc).
			^((price * (100 - thissize) / 100) asInteger)
		]
		ifFalse: [^0].</body>

<body package="SpaceTrader" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	cargo := Cargo new.
	wormhole := nil.
	xylocation := nil.
	mercenaries := nil.
	visited := nil.
	techlevel := nil.
	polsystem := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SpaceTrader.Planet</class-id> <category>accessing</category>

<body package="SpaceTrader" selector="cargo">cargo
	^cargo</body>

<body package="SpaceTrader" selector="cargo:">cargo: anObject
	cargo := anObject</body>

<body package="SpaceTrader" selector="mercenaries">mercenaries
	^mercenaries</body>

<body package="SpaceTrader" selector="mercenaries:">mercenaries: anObject
	mercenaries := anObject</body>

<body package="SpaceTrader" selector="planetsize">planetsize
	^planetsize</body>

<body package="SpaceTrader" selector="planetsize:">planetsize: anObject
	planetsize := anObject</body>

<body package="SpaceTrader" selector="polsystem">polsystem
	^polsystem</body>

<body package="SpaceTrader" selector="polsystem:">polsystem: anObject
	polsystem := anObject</body>

<body package="SpaceTrader" selector="techlevel">techlevel
	^techlevel</body>

<body package="SpaceTrader" selector="techlevel:">techlevel: anObject
	techlevel := anObject</body>

<body package="SpaceTrader" selector="visited">visited
	^visited</body>

<body package="SpaceTrader" selector="visited:">visited: anObject
	visited := anObject</body>

<body package="SpaceTrader" selector="wormhole">wormhole
	^wormhole</body>

<body package="SpaceTrader" selector="wormhole:">wormhole: anObject
	wormhole := anObject</body>

<body package="SpaceTrader" selector="xylocation">xylocation
	^xylocation</body>

<body package="SpaceTrader" selector="xylocation:">xylocation: anObject
	xylocation := anObject</body>
</methods>

</st-source>
